package com.wudizaba.pg.controller;


import com.wudizaba.pg.domain.QUery.PageQuery;
import com.wudizaba.pg.domain.DTO.StoredProcedureDrillDTO;
import com.wudizaba.pg.domain.po.StoredProcedureDrill;
import com.wudizaba.pg.service.IStoredProcedureDrillService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author k
 * @since 2024-05-02
 */
@RestController
@RequestMapping("/stored-procedure-drill")
@Api(tags = "mybatis调用pgsql存储过程controller")
@RequiredArgsConstructor
@Slf4j
public class StoredProcedureDrillController {

    private final IStoredProcedureDrillService storedProcedureDrillService;

    @ApiOperation("mybatis调用pgsql存储过程-新增接口")
    @PostMapping("/save")
    public String saveStoredProcedureDrill(@ApiParam(value = "id", required = true)@RequestParam Integer id) {
        return storedProcedureDrillService.saveStoredProcedureDrill(id);
    }

    @ApiOperation("mybatis调用pgsql存储过程-修改接口")
    @PostMapping("/update")
    public String updateStoredProcedureDrill(@ApiParam(value = "storedProcedureDrill数据", required = true)@RequestBody StoredProcedureDrillDTO storedProcedureDrill) {
        return storedProcedureDrillService.updateStoredProcedureDrill(storedProcedureDrill);
    }
    @ApiOperation("mybatis调用pgsql存储过程-删除接口")
    @DeleteMapping("/delete")
    public String deleteStoredProcedureDrill(@ApiParam(value = "id", required = true)@RequestParam Integer id) {
        return storedProcedureDrillService.deleteStoredProcedureDrill(id);
    }
    @ApiOperation("mybatis调用pgsql存储过程-查询接口")
    @GetMapping("/get")
    public List<StoredProcedureDrill> getStoredProcedureDrill(@ApiParam(value = "id") PageQuery pageQuery) {
        return storedProcedureDrillService.getStoredProcedureDrill(pageQuery);
    }

}
